package com.limeng.datastruts.work;

import java.util.HashMap;
import java.util.Map;

public class ArrayDuplicate {

    public static void main(String[] args) {
        int[] nums = {5,1,2,3,9};
        System.out.println(isAllOnce(nums));
    }

    /**
     * 判断数组中所有元素都出现一次
     * @param nums
     * @return
     */
    public static String isAllOnce(int[] nums){
        Map<Integer,Integer> map = new HashMap<>();
        for (int num : nums){
            if (map.containsKey(num)){
                return "NO";
            }
            map.put(num,1);
        }
        return "YES";
    }
}
